package io.renren.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.entity.SbjsglEntity;
import io.renren.service.SbjsglService;
import io.renren.utils.PageUtils;
import io.renren.utils.Query;
import io.renren.utils.R;


/**
 * 商保基数
 * 
 * @author zhangheng
 * @email zh_123shmily@163.com
 * @date 2017-07-26 14:56:41
 */
@RestController
@RequestMapping("sbjsgl")
public class SbjsglController {
	@Autowired
	private SbjsglService sbjsglService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("sbjsgl:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<SbjsglEntity> sbjsglList = sbjsglService.queryList(query);
		int total = sbjsglService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(sbjsglList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{sbjsglId}")
	@RequiresPermissions("sbjsgl:info")
	public R info(@PathVariable("sbjsglId") Integer sbjsglId){
		SbjsglEntity sbjsgl = sbjsglService.queryObject(sbjsglId);
		
		return R.ok().put("sbjsgl", sbjsgl);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("sbjsgl:save")
	public R save(@RequestBody SbjsglEntity sbjsgl){
		sbjsglService.save(sbjsgl);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("sbjsgl:update")
	public R update(@RequestBody SbjsglEntity sbjsgl){
		sbjsglService.update(sbjsgl);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("sbjsgl:delete")
	public R delete(@RequestBody Integer[] sbjsglIds){
		sbjsglService.deleteBatch(sbjsglIds);
		
		return R.ok();
	}
	
}
